package com.kaili.controller.pda.v1;

import com.kaili.common.exception.BaseExcept;
import com.kaili.db.service.IHsEwbsSignService;
import com.kaili.pojo.dto.sign.SignAddDTO;
import com.kaili.pojo.entity.HsEwbsSignDetail;
import com.kaili.version.ApiVersion;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@Api(tags = "[pda]签收服务", description = "[pda]签收服务API")
@RestController("signControllerP")
@ApiVersion(1)
@RequestMapping("/{api_version}")
public class SignController {
    @Autowired
    private IHsEwbsSignService signService;

    @PostMapping("/p/signs/bat")
    @ApiOperation(value = "[pda]新增批量签收")
    public List<List<HsEwbsSignDetail>> addSignByPDA(@RequestBody List<SignAddDTO> req) throws BaseExcept {
        List<List<HsEwbsSignDetail>> list = new ArrayList<>();
        for (SignAddDTO signAddBean : req) {
            int flag = signService.createSignDateByBS(signAddBean);
            if (flag != 0){
                list.add(signAddBean.getLst());
            }
        }
        return list;
    }
}
